#include <stdio.h>

struct carpet_s {
	int		x, y; 
	int		len_x, len_y; 
}; 

#define MAX_N	100000

struct carpet_s  g_carpet[MAX_N]; 
int	N = 0; 
int px, py; 

int main()
{
	int	i; 
	struct carpet_s *c; 
	int	last = -1; 
	
	scanf("%d", &N); 
	for (i=0; i<N; i++) {
		c = &g_carpet[i]; 
		scanf("%d %d %d %d", &c->x, &c->y, &c->len_x, &c->len_y); 
	}
	scanf("%d %d", &px, &py); 
	
	for (i=0; i<N; i++) {
		c = &g_carpet[i]; 
		if (px>=c->x && px<=(c->x+c->len_x) && py>=c->y && py<=(c->y+c->len_y)) 
			last = i + 1; 
	}
	printf("%d", last); 
	return 0; 
}


